package main

import (
	"fmt"
	"log"
	"net/rpc"
)

const (
	OK       = "OK"
	ErrNoKey = "ErrNoKey"
)

type Err string

type PutArgs struct {
	Key   string
	Value string
}

type PutReply struct {
	Err Err
}

type GetArgs struct {
	Key string
}

type GetReply struct {
	Err   Err
	Value string
}

func main() {
	client, err := rpc.Dial("tcp", "127.0.0.1:1234")
	if err != nil {
		log.Fatal("dialing:", err)
	}
	putArgs := PutArgs{"subject", "6.824"}
	putReply := PutReply{}
	client.Call("KV.Put", &putArgs, &putReply)
	fmt.Printf("Put subject: %s\n", putReply.Err)

	// getArgs := GetArgs{"subject"}
	// getReply := GetReply{}
	// client.Call("KV.Get", &getArgs, &getReply)
	// fmt.Printf("Get subject: %s : %s\n", getReply.Value, getReply.Err)

	getArgs := GetArgs{"subject"}
	getReply := GetReply{}
	client.Call("KV.Get", &getArgs, &getReply)
	fmt.Printf("Get subject: %s : %s\n", getReply.Value, getReply.Err)

	client.Close()
}
